package me.spring.cloud.common.components.util.enums;

import me.spring.cloud.common.components.util.enums.inter.EnumLeab;
import me.spring.cloud.common.components.util.enums.inter.RegularEnum;
import java.util.regex.Pattern;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description: 字符串类型
 * @author: luffy
 * @create: 2018-07-20 16:37
 **/
@Getter
@AllArgsConstructor
public enum StringTypeEnum implements RegularEnum<String>, EnumLeab<String> {
  CHINESS_ENGLISH_NUMBER("^[\u4e00-\u9fa5_a-zA-Z0-9]+$", "中文+英文+数字"),
  CHINESS_ENGLISH("^[\u4e00-\u9fa5_a-zA-Z]+$", "中文+英文"),
  CHINESS("^[\u4e00-\u9fa5]+$*", "中文"),
  ENGLISH_NUMBER("^[a-zA-Z0-9]+$", "英文+数字"),
  ENGLISH("^[a-zA-Z]+$", "英文"),
  FIRST_ENGLISH_AND_NUMBER("^[a-zA-Z](1)[0-9]+$", "首字母英文+数字"),
  NUMBER_UP("^\\d(?:(?<=0)1|(?<=1)2|(?<=2)3|(?<=3)4|(?<=4)5|(?<=5)6|(?<=6)7|(?<=7)8|(?<=8)9){5,}$", "数字up"),
  NUMBER_DOWN("^\\d(?:(?>=9)8|(?>=8)7|(?>=7)6|(?>=6)5|(?>=5)4|(?>=4)3|(?>=3)2|(?>=2)1|(?>=1)0){5,}$", "数字down"),
  SAME_NUMBER("^(?:([0-9])\\1{5,})+$", "数字same"),
  ;
  private String regular;
  private String leab;

  public boolean matches(String string) {
    Pattern pattern = Pattern.compile(this.regular);
    return pattern.matcher(string).matches();
  }

}
